<template>
    <div class="website-filing">
        <el-card shadow="never" class="!border-none">
            <div class="mb-5">站点底部版权备案信息设置</div>
            <el-form ref="form" class="ls-form" label-width="100px">
                <div class="bg-fill-lighter py-4">
                    <el-form-item label="显示内容" prop="name">
                        <div class="w-80">
                            <div>
                                <el-input
                                    v-model="formData.recordNumber"
                                    placeholder="请输入html 备案号"
                                />
                            </div>
                        </div>
                    </el-form-item>
                    <el-form-item label="跳转链接" prop="link">
                        <div class="w-80">
                            <div>
                                <el-input
                                    v-model="formData.caseNumber"
                                    placeholder="请输入公安 接入链接"
                                />
                            </div>
                        </div>
                    </el-form-item>
                </div>
            </el-form>
        </el-card>
        
        <footer-btns>
            <el-button type="primary" @click="handleSubmit">保存</el-button>
        </footer-btns>
    </div>
</template>

<script lang="ts" setup>
import {getCopyright, setCopyright} from '@/api/setting/website'
import feedback from '@/utils/feedback'

// 表单数据
const formData = reactive({
    recordNumber: '',
    caseNumber: ''
})

/**
 * 设置备案信息
 */
async function handleSubmit() {
    await setCopyright(formData)
    feedback.msgSuccess('操作成功')
    await getCopyrightData()
}

/**
 *  获取备案信息
 */
async function getCopyrightData() {
    try {
        const respond = await getCopyright();
        if (respond) {
            Object.assign(formData, respond);
        }
    } catch (error) {
        console.error('获取备案信息失败', error);
    }
}

onMounted(() => {
    getCopyrightData()
})
</script>